package cn.seqdata.forecast.model.lstm;

import cn.seqdata.forecast.model.AbstractModel;
import cn.seqdata.forecast.model.ModelParams;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.joda.time.DateTimeConstants;

public class PythonLstmModel extends AbstractModel<ModelParams> {
	private final ObjectMapper jsonMapper = new ObjectMapper();
	private final double[] fvals = new double[DateTimeConstants.MINUTES_PER_DAY];

	@Override
	public void learn(double[] values) {
//		String cmd = "ssh -l root m3 /root/dist/psg_pred/psg_pred";
//		Process process = Runtime.getRuntime()
//			.exec(cmd);
//
//		OutputStream os = process.getOutputStream();
//		InputStream is = process.getInputStream();
//
//		PythonMap ivals = new PythonMap();
//		jsonMapper.writeValue(os, ivals);
//		IOUtils.closeQuietly(os);
//
//		process.waitFor();
//		if (0 == process.exitValue()) {
//			PythonMap pythonMap = jsonMapper.readValue(is, PythonMap.class);
//			pythonMap.count.forEach((k, v) -> {
//				DateTime dt = new DateTime(k, DateTimeZone.UTC);
//				int minutes = dt.toLocalTime()
//					.getMillisOfDay() / DateTimeConstants.MILLIS_PER_MINUTE;
//				values[5][minutes / 30 - 12] = v;
//			});
//
//			for (int j = 0; j < 36; ++j) {
//				for (int i = 0; i < 6; ++i) {
//					System.out.print(values[i][j]);
//					System.out.print('\t');
//				}
//				System.out.println();
//			}
//		} else {
//			IOUtils.copy(process.getErrorStream(), System.out);
//		}
	}

	@Override
	public double[] forecast(int n) {
		return new double[0];
	}

	@Override
	public AbstractModel<ModelParams> create(ModelParams params) {
		return null;
	}
}
